/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package schedulerManagerment.Scheduler;

import Application.MarvellFrame;
import DataServices.LoadingBean;
import DataServices.TransactBean;
import connection.Configuration;
import java.awt.Color;
import java.sql.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.UIManager;
import schedulerManagerment.SeekerManager.gui.SeekerManagerForm;
import schedulerManagerment.SkillFieldManager.ManageField_Skill;
import schedulerManagerment.Vacancy.VacancyManager;
import schedulerManagerment.company.CompanyManager;

/**
 *
 * @author DOANTUNGANH
 */
public class ScheduleManagement extends javax.swing.JFrame implements MarvellFrame {

    private int id;
    LoadingBean loading = new LoadingBean();
    TransactBean transact = new TransactBean();
    // Connection conn to connect database
    public static Connection conn = null;
    private boolean isField = false;
    private boolean isConcur = false;
    private boolean isDate = false;
    private int selectedRemainDays = 0;
    private Calendar dateScheduled = null;
    private int vacancyIdScheduled;
    private int seekerIdScheduled;
    private int schedulerIdScheduled;
    private String selectedSeekerField = "";
    private String selectedVacancyField = "";
    private int selectedSeekerID = 0;
    private int selectedVacancyID = 0;
//    Query used in table seeker
    public String seekerListTable_SQL = "SELECT S.ID, S.NAME AS 'FULLNAME', F.NAME AS 'FIELD', CASE S.STATUS WHEN  0 THEN 'waiting' WHEN 1 THEN 'arranged' END AS 'STATUS' FROM SEEKER S INNER JOIN FIELD F ON S.FIELDID = F.ID WHERE STATUS <> 2";
//    Query used in Detail Selected seeker
    public String seekerDetailTable_SQL = "SELECT DATEOFBIRTH,PHONE,ADDRESS,EMAIL,WEBSITE,GENDER,ID FROM SEEKER";
//    Query used in skill section
    public String seekerSkill_SQL = "SELECT B.NAME FROM SEEKERSKILL_DETAIL A INNER JOIN SKILL B ON A.SKILLID = B.ID WHERE SEEKERID = ";
//    Query used in Interview Calendar of selected seeker
    public String seekerInterviewHistory_SQL = "SELECT ID,DATE,INTERVIEWER,COMPANY,RESULT,CASE CHANGEREQUEST  WHEN  1 THEN 'Yes' WHEN 0 THEN 'No' END AS 'REQUEST',SALARY,SCHEDULER FROM SUB WHERE SEEKERID = ";
//    Query used in table seeker filtered by options
    public String seekerListTable_SQL_FILTER = "SELECT S.ID, S.NAME AS 'FULLNAME', F.NAME AS 'FIELD', CASE S.STATUS WHEN  0 THEN 'waiting' WHEN 1 THEN 'arranged' END AS 'STATUS' FROM SEEKER S INNER JOIN FIELD F ON S.FIELDID = F.ID WHERE STATUS <> 2 AND ";
//    Query used in vacancy list Table filtered by options
    public String vacancyListTable_SQL_FILTER = "SELECT ID, COMPANY,FIELD, AMOUNT AS 'AVAILABLE',[DAY REMAINING], CASE GENDER WHEN  0 THEN 'Female' WHEN 1 THEN 'Male' ELSE 'Both Genders' END AS GENDER, INTERVIEWER FROM VACANY_INTERVIEWER WHERE STATUS <> 2 AND ";
//    Query used in vacancy list table
    public String VacancyListTable_SQL = "SELECT ID, COMPANY,FIELD, AMOUNT AS 'AVAILABLE',[DAY REMAINING], CASE GENDER WHEN  0 THEN 'Female' WHEN 1 THEN 'Male' ELSE 'Both Genders' END AS GENDER, INTERVIEWER FROM VACANY_INTERVIEWER WHERE [DAY REMAINING] > 0 AND AMOUNT >= 1";
//    Query to show required skills
    public String vacancySkill_SQL = "SELECT B.NAME FROM VACANCYSKILL_DETAIL A INNER JOIN SKILL B ON A.SKILLID = B.ID WHERE VACANCYID = ";
    public String interviewerListTable_SQL = "SELECT * FROM INTERVIEWERCOUNT_DETAIL";
//    Query used in table scheduled Calendar of selected interviewer
    public String interviewerSchedule_SQL = "SELECT A.ID,B.NAME,A.DATE,A.COMPANY,CASE A.RESULT WHEN 0 THEN 'Fail' WHEN 1 THEN 'Pass' END AS RESULT,CASE A.CHANGEREQUEST  WHEN  1 THEN 'Yes' WHEN 0 THEN 'No' END AS 'REQUEST',A.SALARY,A.SCHEDULER FROM SUB A INNER JOIN SEEKER B ON A.SEEKERID = B.ID WHERE INTERVIEWER = '";

    /**
     * Creates new form ScheduleManagement
     */
    public ScheduleManagement() {
        initComponents();
        check_Obsolete();
        
        loading.loadTable(seekerListTable_SQL, seekerListTable);
        loading.loadTable(seekerInterviewHistory_SQL + "-1", seekerHistory);
        loading.loadComboBox("SELECT NAME FROM FIELD", fieldComboBox);
        loading.loadComboBox("SELECT NAME FROM FIELD", vacancyFieldComboBox);
        loading.loadTable(VacancyListTable_SQL, vacancyListTable);
        loading.loadTable(interviewerSchedule_SQL + "-1'", interviewerScheduleTable);
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        SeekerPanel = new javax.swing.JPanel();
        fieldComboBox = new javax.swing.JComboBox();
        genderComboBox = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        seekerListTable = new javax.swing.JTable();
        SeekerInfoPanel = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        birthdayLbl = new javax.swing.JLabel();
        phoneLbl = new javax.swing.JLabel();
        addressLbl = new javax.swing.JLabel();
        emailLbl = new javax.swing.JLabel();
        webLbl = new javax.swing.JLabel();
        genderLbl = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        skillArea = new javax.swing.JTextArea();
        SeekerInterviewInfoTable = new javax.swing.JScrollPane();
        seekerHistory = new javax.swing.JTable();
        jLabel12 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        VacancyPanel = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        interviewerScheduleTable = new javax.swing.JTable();
        jLabel17 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        vacancyListTable = new javax.swing.JTable();
        jLabel7 = new javax.swing.JLabel();
        requiredSkills = new javax.swing.JLabel();
        vacancyFieldComboBox = new javax.swing.JComboBox();
        vacancyGenderComboBox = new javax.swing.JComboBox();
        schedulePanel = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        candidateLbl = new javax.swing.JLabel();
        vacancyLbl = new javax.swing.JLabel();
        interviewerLbl = new javax.swing.JLabel();
        jDateChooserSchedule = new com.toedter.calendar.JDateChooser();
        scheduleSubmitBtn = new javax.swing.JButton();
        btnLoout = new javax.swing.JButton();
        btnSeeker = new javax.swing.JButton();
        btnVacancy = new javax.swing.JButton();
        btnCompany = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        fieldConflictLbl = new javax.swing.JLabel();
        concurWarningLbl = new javax.swing.JLabel();
        dateWarningLbl = new javax.swing.JLabel();
        handleRequestButton = new javax.swing.JButton();
        accountingBtn = new javax.swing.JButton();
        refreshBtn = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        exitMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        contentsMenuItem = new javax.swing.JMenuItem();
        aboutMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        SeekerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "JOB SEEKERS", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        fieldComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All fields" }));
        fieldComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fieldComboBoxActionPerformed(evt);
            }
        });

        genderComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Both genders", "Male only", "Female only" }));
        genderComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                genderComboBoxActionPerformed(evt);
            }
        });

        seekerListTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        seekerListTable.setGridColor(new java.awt.Color(240, 240, 240));
        seekerListTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                seekerListTableMousePressed(evt);
            }
        });
        jScrollPane1.setViewportView(seekerListTable);

        SeekerInfoPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel6.setText("Birthday");

        jLabel5.setText("Phone");

        jLabel1.setText("Address");

        jLabel2.setText("Email");

        jLabel3.setText("Website");

        jLabel4.setText("Gender");

        birthdayLbl.setText("..............................");

        phoneLbl.setText("..............................");

        addressLbl.setText("..............................");

        emailLbl.setText("..............................");

        webLbl.setText("..............................");

        genderLbl.setText("..............................");

        jLabel13.setText("Skills : ");

        jScrollPane2.setBorder(null);
        jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

        skillArea.setBackground(new java.awt.Color(240, 240, 240));
        skillArea.setColumns(20);
        skillArea.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N
        skillArea.setRows(5);
        jScrollPane2.setViewportView(skillArea);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jLabel13)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jScrollPane2))
                .addContainerGap())
        );

        javax.swing.GroupLayout SeekerInfoPanelLayout = new javax.swing.GroupLayout(SeekerInfoPanel);
        SeekerInfoPanel.setLayout(SeekerInfoPanelLayout);
        SeekerInfoPanelLayout.setHorizontalGroup(
            SeekerInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SeekerInfoPanelLayout.createSequentialGroup()
                .addGroup(SeekerInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(SeekerInfoPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(SeekerInfoPanelLayout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addGroup(SeekerInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(SeekerInfoPanelLayout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addGap(18, 18, 18)
                                .addComponent(birthdayLbl))
                            .addGroup(SeekerInfoPanelLayout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(jLabel5)
                                .addGap(18, 18, 18)
                                .addComponent(phoneLbl))
                            .addGroup(SeekerInfoPanelLayout.createSequentialGroup()
                                .addGap(1, 1, 1)
                                .addComponent(jLabel1)
                                .addGap(18, 18, 18)
                                .addComponent(addressLbl))
                            .addGroup(SeekerInfoPanelLayout.createSequentialGroup()
                                .addGap(16, 16, 16)
                                .addComponent(jLabel2)
                                .addGap(18, 18, 18)
                                .addComponent(emailLbl))
                            .addGroup(SeekerInfoPanelLayout.createSequentialGroup()
                                .addGap(1, 1, 1)
                                .addComponent(jLabel3)
                                .addGap(18, 18, 18)
                                .addComponent(webLbl))
                            .addGroup(SeekerInfoPanelLayout.createSequentialGroup()
                                .addGap(5, 5, 5)
                                .addComponent(jLabel4)
                                .addGap(18, 18, 18)
                                .addComponent(genderLbl)))))
                .addContainerGap(55, Short.MAX_VALUE))
        );
        SeekerInfoPanelLayout.setVerticalGroup(
            SeekerInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SeekerInfoPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(SeekerInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(birthdayLbl))
                .addGap(6, 6, 6)
                .addGroup(SeekerInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(phoneLbl))
                .addGap(6, 6, 6)
                .addGroup(SeekerInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(addressLbl))
                .addGap(6, 6, 6)
                .addGroup(SeekerInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(emailLbl))
                .addGap(4, 4, 4)
                .addGroup(SeekerInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(webLbl))
                .addGap(6, 6, 6)
                .addGroup(SeekerInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(genderLbl))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        seekerHistory.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        seekerHistory.setGridColor(new java.awt.Color(240, 240, 240));
        SeekerInterviewInfoTable.setViewportView(seekerHistory);

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel12.setText("Interview Calendar of selected seeker");

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel14.setText("Detail information of seleted seeker");

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel15.setText("Filters : ");

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel16.setText("List of job seekers");

        javax.swing.GroupLayout SeekerPanelLayout = new javax.swing.GroupLayout(SeekerPanel);
        SeekerPanel.setLayout(SeekerPanelLayout);
        SeekerPanelLayout.setHorizontalGroup(
            SeekerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SeekerPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(SeekerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel12)
                    .addGroup(SeekerPanelLayout.createSequentialGroup()
                        .addGroup(SeekerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(SeekerPanelLayout.createSequentialGroup()
                                .addComponent(jLabel15)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(fieldComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(genderComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel16))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(SeekerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(SeekerInfoPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(SeekerInterviewInfoTable))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        SeekerPanelLayout.setVerticalGroup(
            SeekerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SeekerPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(SeekerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(fieldComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(genderComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(SeekerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(jLabel14))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(SeekerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(SeekerInfoPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(jLabel12)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(SeekerInterviewInfoTable, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE)
                .addContainerGap())
        );

        VacancyPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "JOB AVAILABLE", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        interviewerScheduleTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        interviewerScheduleTable.setGridColor(new java.awt.Color(240, 240, 240));
        jScrollPane5.setViewportView(interviewerScheduleTable);

        jLabel17.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel17.setText("Scheduled Calendar of selected interviewer");

        vacancyListTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        vacancyListTable.setGridColor(new java.awt.Color(240, 240, 240));
        vacancyListTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                vacancyListTableMousePressed(evt);
            }
        });
        jScrollPane3.setViewportView(vacancyListTable);

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel7.setText("Required Skills : ");

        requiredSkills.setText("......");

        vacancyFieldComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All fields" }));
        vacancyFieldComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vacancyFieldComboBoxActionPerformed(evt);
            }
        });

        vacancyGenderComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Both genders", "Male only", "Female only" }));
        vacancyGenderComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vacancyGenderComboBoxActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout VacancyPanelLayout = new javax.swing.GroupLayout(VacancyPanel);
        VacancyPanel.setLayout(VacancyPanelLayout);
        VacancyPanelLayout.setHorizontalGroup(
            VacancyPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(VacancyPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(VacancyPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(VacancyPanelLayout.createSequentialGroup()
                        .addGroup(VacancyPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 599, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel17)
                            .addGroup(VacancyPanelLayout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(requiredSkills))
                            .addGroup(VacancyPanelLayout.createSequentialGroup()
                                .addComponent(vacancyFieldComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(49, 49, 49)
                                .addComponent(vacancyGenderComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );

        VacancyPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {vacancyFieldComboBox, vacancyGenderComboBox});

        VacancyPanelLayout.setVerticalGroup(
            VacancyPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(VacancyPanelLayout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(VacancyPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(vacancyFieldComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(vacancyGenderComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(VacancyPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(requiredSkills)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
                .addComponent(jLabel17)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        schedulePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Choose details to schedule interview", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel8.setText("Candidate :");

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel9.setText("Vacancy :");

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel10.setText("Interviewer:");

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel11.setText("Date :");

        candidateLbl.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        candidateLbl.setForeground(new java.awt.Color(0, 0, 255));
        candidateLbl.setText("....................................................");

        vacancyLbl.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        vacancyLbl.setForeground(new java.awt.Color(0, 0, 255));
        vacancyLbl.setText("....................................................");

        interviewerLbl.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        interviewerLbl.setForeground(new java.awt.Color(0, 0, 255));
        interviewerLbl.setText("....................................................");

        jDateChooserSchedule.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                jDateChooserSchedulePropertyChange(evt);
            }
        });

        scheduleSubmitBtn.setText("Schedule !");
        scheduleSubmitBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                scheduleSubmitBtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout schedulePanelLayout = new javax.swing.GroupLayout(schedulePanel);
        schedulePanel.setLayout(schedulePanelLayout);
        schedulePanelLayout.setHorizontalGroup(
            schedulePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(schedulePanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(schedulePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(schedulePanelLayout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(candidateLbl)
                        .addGap(30, 30, 30)
                        .addComponent(jLabel9)
                        .addGap(18, 18, 18)
                        .addComponent(vacancyLbl)
                        .addGap(30, 30, 30)
                        .addComponent(jLabel10))
                    .addComponent(scheduleSubmitBtn))
                .addGap(18, 18, 18)
                .addComponent(interviewerLbl)
                .addGap(51, 51, 51)
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jDateChooserSchedule, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(144, 144, 144))
        );
        schedulePanelLayout.setVerticalGroup(
            schedulePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, schedulePanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(schedulePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jDateChooserSchedule, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(schedulePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel8)
                        .addComponent(candidateLbl)
                        .addComponent(jLabel9)
                        .addComponent(vacancyLbl)
                        .addComponent(jLabel10)
                        .addComponent(interviewerLbl)
                        .addComponent(jLabel11)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(scheduleSubmitBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(33, 33, 33))
        );

        btnLoout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Import Document.png"))); // NOI18N
        btnLoout.setText("log out");
        btnLoout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLooutActionPerformed(evt);
            }
        });

        btnSeeker.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Users.png"))); // NOI18N
        btnSeeker.setText("Seeker manager");
        btnSeeker.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSeekerActionPerformed(evt);
            }
        });

        btnVacancy.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Users.png"))); // NOI18N
        btnVacancy.setText("Vacancy");
        btnVacancy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnVacancyActionPerformed(evt);
            }
        });

        btnCompany.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Briefcase.png"))); // NOI18N
        btnCompany.setText("Company");
        btnCompany.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCompanyActionPerformed(evt);
            }
        });

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Write Document.png"))); // NOI18N
        jButton1.setText("Skill & field");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Warning"));

        fieldConflictLbl.setForeground(java.awt.Color.red);
        fieldConflictLbl.setText("                                          ");

        concurWarningLbl.setForeground(new java.awt.Color(255, 0, 0));
        concurWarningLbl.setText("                                                    ");

        dateWarningLbl.setForeground(java.awt.Color.red);
        dateWarningLbl.setText("                                                          ");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(fieldConflictLbl)
                    .addComponent(concurWarningLbl)
                    .addComponent(dateWarningLbl))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {concurWarningLbl, dateWarningLbl, fieldConflictLbl});

        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(fieldConflictLbl)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(concurWarningLbl)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(dateWarningLbl))
        );

        handleRequestButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/alert on.png"))); // NOI18N
        handleRequestButton.setText("Handle Requests");
        handleRequestButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                handleRequestButtonActionPerformed(evt);
            }
        });

        accountingBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/MoneyIcon.png"))); // NOI18N
        accountingBtn.setText("Accounting");
        accountingBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                accountingBtnActionPerformed(evt);
            }
        });

        refreshBtn.setText("Refresh");
        refreshBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshBtnActionPerformed(evt);
            }
        });

        fileMenu.setMnemonic('f');
        fileMenu.setText("File");

        exitMenuItem.setMnemonic('x');
        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setMnemonic('h');
        helpMenu.setText("Help");

        contentsMenuItem.setMnemonic('c');
        contentsMenuItem.setText("Contents");
        helpMenu.add(contentsMenuItem);

        aboutMenuItem.setMnemonic('a');
        aboutMenuItem.setText("About");
        aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aboutMenuItemActionPerformed(evt);
            }
        });
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(schedulePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 1092, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(28, 28, 28)
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(SeekerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(btnSeeker)
                                .addGap(18, 18, 18)
                                .addComponent(btnVacancy, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(28, 28, 28)
                                .addComponent(btnCompany, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(28, 28, 28)
                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(29, 29, 29)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(VacancyPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(handleRequestButton, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(41, 41, 41)
                                .addComponent(accountingBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(refreshBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGap(18, 18, 18)
                                .addComponent(btnLoout)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(18, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnSeeker)
                    .addComponent(btnCompany)
                    .addComponent(btnVacancy)
                    .addComponent(jButton1)
                    .addComponent(btnLoout)
                    .addComponent(handleRequestButton, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(accountingBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(refreshBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(SeekerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(VacancyPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(schedulePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        System.exit(0);
    }//GEN-LAST:event_exitMenuItemActionPerformed

    private void seekerListTableMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_seekerListTableMousePressed
        // TODO add your handling code here:

        int row = this.seekerListTable.getSelectedRow();
        JTable tempTbl = new JTable();
        loading.loadTable(seekerDetailTable_SQL, tempTbl);
        selectedSeekerField = (String) getCellObject(seekerListTable, row, 2);
        selectedSeekerID = (int) getCellObject(seekerListTable, row, 0);
        Calendar cal = Calendar.getInstance();
        Timestamp tstamp = (Timestamp) getCellObject(tempTbl, row, 0);
        cal.setTime(tstamp);
        this.birthdayLbl.setText(cal.get(Calendar.DAY_OF_MONTH) + " - " + cal.get(Calendar.MONTH) + " - " + cal.get(Calendar.YEAR));
        this.phoneLbl.setText(getCellObject(tempTbl, row, 1).toString());
        this.addressLbl.setText(getCellObject(tempTbl, row, 2).toString());
        this.emailLbl.setText(getCellObject(tempTbl, row, 3).toString());
        this.candidateLbl.setText(getCellObject(seekerListTable, row, 1).toString());
        seekerIdScheduled = Integer.parseInt(getCellObject(seekerListTable, row, 0).toString());
        if (Boolean.parseBoolean(getCellObject(tempTbl, row, 5).toString())) {
            this.genderLbl.setText("male");
        } else {
            this.genderLbl.setText("female");
        }
        if ((getCellObject(tempTbl, row, 4)) != null) {
            this.webLbl.setText(getCellObject(tempTbl, row, 4).toString());
            this.webLbl.setForeground(Color.black);
        } else {
            this.webLbl.setText("not available");
            this.webLbl.setForeground(Color.blue);
        }
        Vector<String> vtemp = new Vector<String>();
        vtemp = loadVectorData(seekerSkill_SQL + getCellObject(tempTbl, row, 6).toString());
        String tempS = "";
        this.skillArea.setText(tempS);
        for (int i = 1; i <= vtemp.size(); i++) {
            tempS += (i + ". " + vtemp.elementAt(i - 1) + "\n");
            this.skillArea.setText(tempS);
        }

        loading.loadTable(seekerInterviewHistory_SQL + getCellObject(tempTbl, row, 6).toString(), seekerHistory);
        warningNote();
        if (isConcur == false || isField == false || isDate == false) {
            this.scheduleSubmitBtn.setEnabled(false);
        } else {
            this.scheduleSubmitBtn.setEnabled(true);
        }
    }//GEN-LAST:event_seekerListTableMousePressed

    private void fieldComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fieldComboBoxActionPerformed
        // TODO add your handling code here:
        seekerFilter();
    }//GEN-LAST:event_fieldComboBoxActionPerformed

    private void genderComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genderComboBoxActionPerformed
        // TODO add your handling code here:
        seekerFilter();
    }//GEN-LAST:event_genderComboBoxActionPerformed

    private void vacancyListTableMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_vacancyListTableMousePressed
        // TODO add your handling code here:
        int row = this.vacancyListTable.getSelectedRow();
        selectedVacancyField = (String) getCellObject(vacancyListTable, row, 2);
        selectedVacancyID = (int) getCellObject(vacancyListTable, row, 0);
        selectedRemainDays = (int) getCellObject(vacancyListTable, row, 4);
        Vector<String> vtemp = new Vector<String>();
        vtemp = loadVectorData(vacancySkill_SQL + getCellObject(vacancyListTable, row, 0).toString());
        String tempS = "";
        for (int i = 1; i <= vtemp.size(); i++) {
            tempS += (i + ". " + vtemp.elementAt(i - 1) + "    ");
            this.requiredSkills.setText(tempS);
        }
        this.vacancyLbl.setText(getCellObject(vacancyListTable, row, 1).toString() + " (Vacancy Code : " + getCellObject(vacancyListTable, row, 0).toString() + " )");
        this.interviewerLbl.setText(getCellObject(vacancyListTable, row, 6).toString());
        vacancyIdScheduled = Integer.parseInt(getCellObject(vacancyListTable, row, 0).toString());
        loading.loadTable(this.interviewerSchedule_SQL + getCellObject(vacancyListTable, row, 6).toString() + "'", this.interviewerScheduleTable);
        warningNote();
        if (isConcur == false || isField == false || isDate == false) {
            this.scheduleSubmitBtn.setEnabled(false);
        } else {
            this.scheduleSubmitBtn.setEnabled(true);
        }
    }//GEN-LAST:event_vacancyListTableMousePressed

    private void jDateChooserSchedulePropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jDateChooserSchedulePropertyChange
        // TODO add your handling code here:
        Calendar cal = this.jDateChooserSchedule.getCalendar();
        Calendar currentCal = Calendar.getInstance();
        System.out.println("current: " + currentCal.get(Calendar.DAY_OF_MONTH) + "/" + (currentCal.get(Calendar.MONTH) + 1) + "/" + currentCal.get(Calendar.YEAR));
        Calendar tempCal = Calendar.getInstance();
        System.out.println("ngay hom nay : " + tempCal.get(Calendar.DAY_OF_MONTH) + "/" + (tempCal.get(Calendar.MONTH) + 1) + "/" + tempCal.get(Calendar.YEAR));
        tempCal.add(Calendar.DATE, selectedRemainDays);
        System.out.println(selectedRemainDays + "");
        System.out.println("ngay het han : " + tempCal.get(Calendar.DAY_OF_MONTH) + "/" + (tempCal.get(Calendar.MONTH) + 1) + "/" + tempCal.get(Calendar.YEAR));
        if ((cal != null) && (cal.after(currentCal)) && (cal.before(tempCal))) {
            dateScheduled = cal;
            dateWarningLbl.setText("");
            isDate = true;
            System.out.println("right date");
        } else {
            dateWarningLbl.setText("Empty or Out of Schedule Date");
            isDate = false;
        }

        if (isConcur == false || isField == false || isDate == false) {
            this.scheduleSubmitBtn.setEnabled(false);
        } else {
            this.scheduleSubmitBtn.setEnabled(true);
        }

    }//GEN-LAST:event_jDateChooserSchedulePropertyChange

    private void scheduleSubmitBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_scheduleSubmitBtnActionPerformed
        // TODO add your handling code here:
        schedulerIdScheduled = getId();
        configConnection();
        String sql = "{call INSERTINTERVIEW(?,?,?,?)}";
        CallableStatement cs;
        try {
            cs = conn.prepareCall(sql);
            java.sql.Date sqlDateScheduled = new java.sql.Date(dateScheduled.getTime().getTime());
            cs.setDate(1, sqlDateScheduled);
            cs.setInt(2, vacancyIdScheduled);
            cs.setInt(3, seekerIdScheduled);
            cs.setInt(4, schedulerIdScheduled);
            System.out.println("Scheduler ID = !!!!! " + schedulerIdScheduled);
            cs.execute();
        } catch (SQLException ex) {
            Logger.getLogger(ScheduleManagement.class.getName()).log(Level.SEVERE, null, ex);
        }
        seekerFilter();
        loading.loadTable(seekerInterviewHistory_SQL + "-1", seekerHistory);
        loading.loadTable(VacancyListTable_SQL, vacancyListTable);
        loading.loadTable(interviewerSchedule_SQL + "-1'", interviewerScheduleTable);

    }//GEN-LAST:event_scheduleSubmitBtnActionPerformed

    private void btnLooutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLooutActionPerformed
        this.exitFrame();
    }//GEN-LAST:event_btnLooutActionPerformed

    private void btnSeekerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSeekerActionPerformed
        seekerManagerFrame = new SeekerManagerForm();
        seekerManagerFrame.startFrame(this);
    }//GEN-LAST:event_btnSeekerActionPerformed

    private void btnVacancyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVacancyActionPerformed
        this.vacancyManagerFrame = new VacancyManager();
        vacancyManagerFrame.startFrame(this);
    }//GEN-LAST:event_btnVacancyActionPerformed

    private void btnCompanyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCompanyActionPerformed
        this.companyFrame = new CompanyManager();
        companyFrame.startFrame(this);
    }//GEN-LAST:event_btnCompanyActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        this.fieldSkillFrame = new ManageField_Skill();
        fieldSkillFrame.startFrame(this);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void vacancyFieldComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vacancyFieldComboBoxActionPerformed
        // TODO add your handling code here:
        vacancyFilter();
    }//GEN-LAST:event_vacancyFieldComboBoxActionPerformed

    private void vacancyGenderComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vacancyGenderComboBoxActionPerformed
        // TODO add your handling code here:
        vacancyFilter();
    }//GEN-LAST:event_vacancyGenderComboBoxActionPerformed

    private void handleRequestButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_handleRequestButtonActionPerformed
        // TODO add your handling code here:
        requestHandleFrame = new RequestHandlingForm();
        requestHandleFrame.startFrame(this);
    }//GEN-LAST:event_handleRequestButtonActionPerformed

    private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_aboutMenuItemActionPerformed

    private void accountingBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_accountingBtnActionPerformed
        // TODO add your handling code here:
        accountingFrame = new Accounting();
        accountingFrame.startFrame(this);
    }//GEN-LAST:event_accountingBtnActionPerformed

    private void refreshBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshBtnActionPerformed
        // TODO add your handling code here:
        loading.loadTable(seekerListTable_SQL, seekerListTable);
        loading.loadTable(seekerInterviewHistory_SQL + "-1", seekerHistory);
        loading.loadComboBox("SELECT NAME FROM FIELD", fieldComboBox);
        loading.loadComboBox("SELECT NAME FROM FIELD", vacancyFieldComboBox);
        loading.loadTable(VacancyListTable_SQL, vacancyListTable);
        loading.loadTable(interviewerSchedule_SQL + "-1'", interviewerScheduleTable);
    }//GEN-LAST:event_refreshBtnActionPerformed
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel SeekerInfoPanel;
    private javax.swing.JScrollPane SeekerInterviewInfoTable;
    private javax.swing.JPanel SeekerPanel;
    private javax.swing.JPanel VacancyPanel;
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JButton accountingBtn;
    private javax.swing.JLabel addressLbl;
    private javax.swing.JLabel birthdayLbl;
    private javax.swing.JButton btnCompany;
    private javax.swing.JButton btnLoout;
    private javax.swing.JButton btnSeeker;
    private javax.swing.JButton btnVacancy;
    private javax.swing.JLabel candidateLbl;
    private javax.swing.JLabel concurWarningLbl;
    private javax.swing.JMenuItem contentsMenuItem;
    private javax.swing.JLabel dateWarningLbl;
    private javax.swing.JLabel emailLbl;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JComboBox fieldComboBox;
    private javax.swing.JLabel fieldConflictLbl;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JComboBox genderComboBox;
    private javax.swing.JLabel genderLbl;
    private javax.swing.JButton handleRequestButton;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JLabel interviewerLbl;
    private javax.swing.JTable interviewerScheduleTable;
    private javax.swing.JButton jButton1;
    private com.toedter.calendar.JDateChooser jDateChooserSchedule;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JLabel phoneLbl;
    private javax.swing.JButton refreshBtn;
    private javax.swing.JLabel requiredSkills;
    private javax.swing.JPanel schedulePanel;
    private javax.swing.JButton scheduleSubmitBtn;
    private javax.swing.JTable seekerHistory;
    private javax.swing.JTable seekerListTable;
    private javax.swing.JTextArea skillArea;
    private javax.swing.JComboBox vacancyFieldComboBox;
    private javax.swing.JComboBox vacancyGenderComboBox;
    private javax.swing.JLabel vacancyLbl;
    private javax.swing.JTable vacancyListTable;
    private javax.swing.JLabel webLbl;
    // End of variables declaration//GEN-END:variables

    // Config Connection
    private void configConnection() {
        Configuration createConn = new Configuration();
        conn = createConn.getConnect();
    }

    private Object getCellObject(JTable table, int row, int column) {
        return table.getModel().getValueAt(row, column);
    }

    private Vector<String> loadVectorData(String sql) {

        ResultSet rs = null;
        PreparedStatement preparedStm = null;
        configConnection();
        Vector<String> temp = new Vector<String>();
        try {
            preparedStm = conn.prepareStatement(sql);
            rs = preparedStm.executeQuery();
            while (rs.next()) {
                temp.add(rs.getString(1));
                System.out.println(rs.getString(1));
            }

        } catch (SQLException ex) {
            ex.printStackTrace();
        } finally {
            if (preparedStm != null) {
                try {
                    preparedStm.close();
                } catch (SQLException ex) {
                    ex.printStackTrace();
                }
            }
        }
        return temp;
    }

    private void seekerFilter() {
        String fValue = null;
        fValue = this.fieldComboBox.getSelectedItem().toString();
        String fieldTemp = null;
        System.out.println(fValue);
        if (fValue != "All fields") {
            fieldTemp = " F.NAME = '" + fValue + "' AND";
        } else {
            fieldTemp = "";
        }
        String gValue = null;
        gValue = this.genderComboBox.getSelectedItem().toString();
        System.out.println(gValue);
        String sex = null;
        if (gValue == "Male only") {
            sex = "1";
        } else if (gValue == "Female only") {
            sex = "0";
        } else {
            sex = "1 OR GENDER = 0";
        }
        loading.loadTable(seekerListTable_SQL_FILTER + fieldTemp + " (GENDER = " + sex + ")", seekerListTable);
    }

    private void vacancyFilter() {
        String fValue = null;
        fValue = this.vacancyFieldComboBox.getSelectedItem().toString();
        String fieldTemp = null;
        if (fValue != "All fields") {
            fieldTemp = " FIELD = '" + fValue + "' AND";
        } else {
            fieldTemp = "";
        }
        String gValue = null;
        gValue = this.vacancyGenderComboBox.getSelectedItem().toString();
        System.out.println(gValue);
        String sex = null;
        if (gValue == "Male only") {
            sex = " = 1";
        } else if (gValue == "Female only") {
            sex = " = 0";
        } else {
            sex = " IS NULL";
        }
        System.out.println(vacancyListTable_SQL_FILTER + fieldTemp + " (GENDER " + sex + ")");
        loading.loadTable(vacancyListTable_SQL_FILTER + fieldTemp + " (GENDER " + sex + ")", vacancyListTable);
    }

    private void warningNote() {
        if (selectedSeekerField.equals(selectedVacancyField)) {
            this.fieldConflictLbl.setText("");
            isField = true;
        } else {
            this.fieldConflictLbl.setText("Job fields not match");
            isField = false;
        }
        String sql = "SELECT * FROM INTERVIEW WHERE SEEKERID = " + selectedSeekerID + " AND VACANCYID = " + selectedVacancyID;
        System.out.println(sql);
        try {
            ResultSet rs = transact.getpreparedStatement(sql).executeQuery();
            isConcur = true;
            concurWarningLbl.setText("");
            while (rs.next()) {
                if (rs != null) {
                    concurWarningLbl.setText("Interview is already scheduled");
                    isConcur = false;
                }
            }

        } catch (SQLException ex) {
            Logger.getLogger(ScheduleManagement.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    private void check_Obsolete() {
        TransactBean transact = new TransactBean();
        ResultSet rs = null;
//        Select all the vacancies which is out of date
        String sql = "SELECT * FROM VACANCY WHERE DATEOFPOST < GETDATE()";
        ArrayList<Integer> outOfDateVacancyID = new ArrayList<Integer>();
        try {
            rs = transact.getpreparedStatement(sql).executeQuery();
//            assign out of date vacancy ID to outOfDateVacancyID vector array
            while (rs.next()) {
                outOfDateVacancyID.add(rs.getInt("ID"));
            }
        } catch (SQLException ex) {
            Logger.getLogger(LoadingBean.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            transact.destroy();
        }

        for (Integer id : outOfDateVacancyID) {
            try {
//                Set status of out of date vacancies to 2
                sql = "UPDATE VACANCY SET STATUS = 2 WHERE ID = " + id;
                transact.getpreparedStatement(sql).executeUpdate();
                transact.destroy();
//                sql = "DELETE FROM INTERVIEW WHERE (RESULT <> 1 AND VACANCYID = " + id + " ) OR (DATE < GETDATE() AND (RESULT IS NULL OR RESULT = 0))";
//                System.out.println(sql);
//                transact.getpreparedStatement(sql).executeUpdate();
            } catch (SQLException ex) {
                Logger.getLogger(LoadingBean.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                transact.destroy();
            }
        }

        ArrayList<Integer> assumedArrangedSeeker = new ArrayList<>();
        try {

//            Select all seekers who is in the states of arranged
            sql = "SELECT * FROM SEEKER WHERE STATUS = 1";
            rs = transact.getpreparedStatement(sql).executeQuery();
            while (rs.next()) {
                assumedArrangedSeeker.add(rs.getInt("ID"));
            }
        } catch (SQLException ex) {
            Logger.getLogger(LoadingBean.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            transact.destroy();
        }

        ArrayList<Integer> realArrangedSeeker = new ArrayList<>();
        try {
//            Select all seekers who is in the interview list and not out of date
            sql = "select distinct seekerID from interview i inner join vacancy v on i.vacancyid = v.id where v.status <> 2";
            rs = transact.getpreparedStatement(sql).executeQuery();
            while (rs.next()) {
                realArrangedSeeker.add(rs.getInt("SEEKERID"));
            }
        } catch (SQLException ex) {
            Logger.getLogger(LoadingBean.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            transact.destroy();
        }

        ArrayList<Integer> doneSeeker = new ArrayList<>();
        try {
//            Select all seekers who already found the job
            sql = "select distinct seekerID from interview where result = 1";
            rs = transact.getpreparedStatement(sql).executeQuery();
            while (rs.next()) {
                doneSeeker.add(rs.getInt("SEEKERID"));
            }
        } catch (SQLException ex) {
            Logger.getLogger(LoadingBean.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            transact.destroy();
        }

        for (Integer i : assumedArrangedSeeker) {
            try {
//                Set status of all seeker to 0, mean waiting
                sql = "UPDATE SEEKER SET STATUS = 0";
                transact.getpreparedStatement(sql).executeUpdate();
            } catch (SQLException ex) {
                Logger.getLogger(LoadingBean.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                transact.destroy();
            }
        }

        for (Integer realID : realArrangedSeeker) {
            for (Integer assumedID : assumedArrangedSeeker) {
//                If an assumed arranged seeker exists in interview list, change status to 1
                if (assumedID == realID) {
                    try {
                        sql = "UPDATE SEEKER SET STATUS = 1 WHERE ID = " + assumedID;
                        transact.getpreparedStatement(sql).executeUpdate();
                    } catch (SQLException ex) {
                        Logger.getLogger(LoadingBean.class.getName()).log(Level.SEVERE, null, ex);
                    } finally {
                        transact.destroy();
                    }
                }
            }
        }


        for (Integer doneID : doneSeeker) {
            for (Integer assumedID : assumedArrangedSeeker) {
//                If an assumed arranged seeker exists in interview list, change status to 1
                if (assumedID == doneID) {
                    try {
                        sql = "UPDATE SEEKER SET STATUS = 2 WHERE ID = " + doneID;
                        transact.getpreparedStatement(sql).executeUpdate();
                    } catch (SQLException ex) {
                        Logger.getLogger(LoadingBean.class.getName()).log(Level.SEVERE, null, ex);
                    } finally {
                        transact.destroy();
                    }
                }
            }
        }


    }

    @Override
    public void startFrame(JFrame app) {
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ScheduleManagement.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ScheduleManagement.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ScheduleManagement.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ScheduleManagement.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        this.root = app;
        this.setVisible(true);
        app.setVisible(false);
    }

    @Override
    public void exitFrame() {
        this.setVisible(false);
        root.setVisible(true);
    }
    private MarvellFrame fieldSkillFrame;
    private MarvellFrame companyFrame;
    private MarvellFrame vacancyManagerFrame;
    private MarvellFrame seekerManagerFrame;
    private MarvellFrame requestHandleFrame;
    private MarvellFrame accountingFrame;
    private JFrame root;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
        System.out.println("ID is set : " + id);
    }
}
